package com.scripts;

import Utilities.Commons;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.List;

/**
 * Created by orlandocampos on 10/17/14.
 */
public class TestTables {

    protected static WebDriver wd;

    @BeforeClass
    public static void setup(){

        wd = new FirefoxDriver();

        wd.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);

    }

    @Test
    public static void TestCase() throws Exception{

        wd.get("http://www.w3schools.com/html/html_tables.asp");

        WebElement table = wd.findElement(By.cssSelector("h2+table:first-of-type"));

        List<WebElement> tdlist = table.findElements(By.tagName("td"));

        System.out.printf(tdlist.get(10).getText());

        //CON XPATH

        System.out.printf("---"+wd.findElement(By.xpath("//*[@id='main']/table[1]/tbody/tr[5]/td[3]")).getText());


        Commons.wait(4);

    }

    @AfterClass
    public static void Close(){
        wd.close();
        wd.quit();

    }
}
